package com.hcbd.tdwt.ui.setting.xingyu.adapter;

import android.app.Activity;
import android.content.Context;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;


import com.hcbd.tdwt.R;

import java.util.List;

public class AutoTestAdapter extends RecyclerView.Adapter<AutoTestAdapter.MyViewHolder>{

    protected final Context mContext;
    private List<String> logList;
    private final LayoutInflater mInflater;
    private OnItemClickListener onItemClickListener;
    public AutoTestAdapter(Context context, List<String> list){
        mContext=context;
        mInflater=((Activity)context).getLayoutInflater();
        logList=list;

    }
    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i){
        View view=mInflater.inflate(R.layout.auto_test_log_item,viewGroup,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i){
        String str=logList.get(i);
        myViewHolder.logText.setText(str);
    }

    @Override
    public int getItemCount(){
        return logList.size();
    }

    public void notifyDataSetChanged(List<String>list){
        logList=list;
        notifyDataSetChanged();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        TextView  logText;


        MyViewHolder(View itemView) {
            super(itemView);
            logText = itemView.findViewById(R.id.logText);

        }
    }

    public interface OnItemClickListener {
        void onClick();

    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }



}
